package com.recipedb.recipedb.repository;

import com.recipedb.recipedb.entity.Tag;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

//小侯
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
//小侯


@Repository
public interface TagRepository extends JpaRepository<Tag, Long> {

    @Query("SELECT t FROM Tag t JOIN RecipeTag rt ON t.id = rt.tagId WHERE rt.recipeId = :recipeId")
    List<Tag> findByRecipeId(@Param("recipeId") Long recipeId);

}
